import allure
from appium import webdriver
from appium.webdriver.webdriver import WebDriver


class BasePage:
    def __init__(self, driver: WebDriver = None):
        if driver is not None:
            self.driver = driver
        else:
            caps = {
                "platformName": "Android",
                "appPackage": "com.tencent.wework",
                "appActivity": "launch.LaunchSplashActivity",
                "noReset": "true",
                'unicodeKeyboard': True,
                'resetKeyboard': True
            }
            self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', caps)
            self.driver.implicitly_wait(5)

    def find(self, by, value):
        # allure.attach(body=self.driver.get_screenshot_as_png(), attachment_type=allure.attachment_type.PNG)
        return self.driver.find_element(by, value)


